package com.crack.nga2.custom;

import android.content.Context;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;
import android.widget.TextView;

import com.crack.nga2.R;

/**
 * Created by Administrator on 2015/12/18.
 */
public class FootLayoutImpl implements ILoadingLayout {
    private View rootView;
    private ImageView bar;
    private TextView text;

    public FootLayoutImpl(Context context) {
        rootView = View.inflate(context, R.layout.pull_footer, null);
        bar = (ImageView) rootView.findViewById(R.id.bar);
        text = (TextView) rootView.findViewById(R.id.text);
    }

    @Override
    public void init(View rootView) {

    }

    @Override
    public View getView() {
        return rootView;
    }

    @Override
    public void pullTo(int x) {
        text.setText("下拉加载更多");
    }

    @Override
    public void stopPull() {

    }

    @Override
    public void startRefresh() {
        text.setText("正在加载...");
        Animation animation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        animation.setDuration(500);
        animation.setRepeatCount(Animation.INFINITE);
        bar.startAnimation(animation);
    }

    @Override
    public void stopRefresh() {
        bar.clearAnimation();
    }
}
